package com.bi.onlineEducation.domain;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * purchase
 *
 * @author
 */
@Entity
@Table(name = "purchase")
@ApiModel(value = "generate.PurchasePo购买信息")
@Data
public class PurchasePo implements Serializable {
    /**
     * 购买主键ID
     */
    @Id
    @Column(name = "p_id")
    @GeneratedValue(generator = "JDBC")
    @ApiModelProperty(value = "购买主键ID")
    private Integer pId;

    /**
     * 购买课程ID
     */
    @Column(name = "c_id")
    @ApiModelProperty(value = "购买课程ID")
    private Integer cId;

    @OneToOne(cascade = CascadeType.DETACH)//PurchasePo是关系的维护端，当删除 PurchasePo，会级联删除 CoursePo
    @JoinColumn(name = "c_id", referencedColumnName = "c_id", insertable = false, updatable = false)
    @JsonIgnoreProperties({"courseType", "login"})
    private CoursePo course;    //PurchasePo中的c_id字段参考CoursePo表中的id字段

    /*@OneToMany(mappedBy = "c_id",cascade=CascadeType.DETACH,fetch=FetchType.LAZY)
    //级联保存、更新、删除、刷新;延迟加载。当删除用户，会级联删除该用户的所有文章
    //拥有mappedBy注解的实体类为关系被维护端
    //mappedBy="c_id"中的CoursePo是CoursePo中的c_id属性
    private List<CoursePo> courseList;//文章列表*/

    /**
     * 购买人ID
     */
    @Column(name = "l_id")
    @ApiModelProperty(value = "购买人ID")
    private Integer lId;

    @OneToOne(cascade = CascadeType.DETACH)//PurchasePo是关系的维护端，当删除 PurchasePo，会级联删除 CoursePo
    @JoinColumn(name = "l_id", referencedColumnName = "l_id", insertable = false, updatable = false)
    private LoginPo login;    //PurchasePo中的c_id字段参考CoursePo表中的id字段


    /**
     * 购买时间
     */
    @Column(name = "p_create_time")
    @ApiModelProperty(value = "购买时间")
    private Date pCreateTime;

    private static final long serialVersionUID = 1L;
}